<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Spring Boot,Spring Security," />










<meta name="description" content="Spring Boot Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化">
<meta name="keywords" content="Spring Boot,Spring Security">
<meta property="og:type" content="article">
<meta property="og:title" content="Spring Boot Security进阶(二)">
<meta property="og:url" content="http://yoursite.com/2018/12/18/Spring-Boot-Security进阶-二/Spring-Boot-Security进阶-二/index.html">
<meta property="og:site_name" content="程序员乌托邦">
<meta property="og:description" content="Spring Boot Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://mdsystem.oss-cn-hangzhou.aliyuncs.com/blog/%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_230da13e-57ed-4fb0-b64f-0be8c304a913.png">
<meta property="og:updated_time" content="2018-12-18T08:21:41.971Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Spring Boot Security进阶(二)">
<meta name="twitter:description" content="Spring Boot Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化">
<meta name="twitter:image" content="https://mdsystem.oss-cn-hangzhou.aliyuncs.com/blog/%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_230da13e-57ed-4fb0-b64f-0be8c304a913.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/12/18/Spring-Boot-Security进阶-二/Spring-Boot-Security进阶-二/"/>





  <title>Spring Boot Security进阶(二) | 程序员乌托邦</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">程序员乌托邦</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/12/18/Spring-Boot-Security进阶-二/Spring-Boot-Security进阶-二/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Wolf、Heart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="程序员乌托邦">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Spring Boot Security进阶(二)</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-12-18T16:03:43+08:00">
                2018-12-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Spring-Boot/" itemprop="url" rel="index">
                    <span itemprop="name">Spring Boot</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Spring-Security/" itemprop="url" rel="index">
                    <span itemprop="name">Spring Security</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="Spring-Boot-Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化"><a href="#Spring-Boot-Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化" class="headerlink" title="Spring Boot Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化"></a>Spring Boot Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化</h3><a id="more"></a>
<p>上一个章节已经实现了对于不同用户拥有不同的操作权限，但是登录还存在着问题。我们可以尝试，输入不存在的用户名或者错误的密码，都会在页面展示“用户名或密码错误”这样的提示。如果我们不需要知道具体的错误原因，给一个笼统的错误提示可以接受，那么上一章节就可以满足需求。</p>
<h1 id="登录返回具体的错误原因"><a href="#登录返回具体的错误原因" class="headerlink" title="登录返回具体的错误原因"></a>登录返回具体的错误原因</h1><ol>
<li><p>首先在之前登录错误路由的方法中加入如下代码</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">System.out.println(request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION));</span><br></pre></td></tr></table></figure>
</li>
<li><p>分别输入错误的账号、密码进行登录，控制台打印如下内容</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">org.springframework.security.authentication.BadCredentialsException: Bad credentials</span><br><span class="line">org.springframework.security.authentication.BadCredentialsException: Bad credentials</span><br></pre></td></tr></table></figure>
</li>
<li><p>根据如上打印的内容我们无法区分具体的错误原因，我们在自定义的CustomerUserDetailService类的loadUserByUsername()方法中判断如果用户不存在抛出的是UsernameNotFoundException异常，为什么返回的却是BadCredentialsException？？？</p>
</li>
<li>打开AbstractUserDetailsAuthenticationProvider类<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">if (user == null) &#123;</span><br><span class="line">	cacheWasUsed = false;</span><br><span class="line"></span><br><span class="line">	try &#123;</span><br><span class="line">		user = retrieveUser(username,</span><br><span class="line">				(UsernamePasswordAuthenticationToken) authentication);</span><br><span class="line">	&#125;</span><br><span class="line">	catch (UsernameNotFoundException notFound) &#123;</span><br><span class="line">		logger.debug(&quot;User &apos;&quot; + username + &quot;&apos; not found&quot;);</span><br><span class="line">        </span><br><span class="line">        // 如果该变量为真，那么就会返回BadCredentialsException</span><br><span class="line">		if (hideUserNotFoundExceptions) &#123;</span><br><span class="line">			throw new BadCredentialsException(messages.getMessage(</span><br><span class="line">					&quot;AbstractUserDetailsAuthenticationProvider.badCredentials&quot;,</span><br><span class="line">					&quot;Bad credentials&quot;));</span><br><span class="line">		&#125;</span><br><span class="line">		else &#123;</span><br><span class="line">			throw notFound;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	Assert.notNull(user,</span><br><span class="line">			&quot;retrieveUser returned null - a violation of the interface contract&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>5.修改该变量为false即可解决我们的问题，之前的配置类修改如下<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line">@Configuration</span><br><span class="line">@EnableGlobalMethodSecurity(prePostEnabled = true)</span><br><span class="line">public class WebSecurityConfigure extends WebSecurityConfigurerAdapter &#123;</span><br><span class="line"></span><br><span class="line">    @Autowired</span><br><span class="line">    private CustomerUserDetailService customerUserDetailService;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    protected void configure(HttpSecurity http) throws Exception &#123;</span><br><span class="line">        http</span><br><span class="line">            .authorizeRequests()</span><br><span class="line">                .antMatchers(&quot;/&quot;)</span><br><span class="line">                .permitAll()</span><br><span class="line">                .anyRequest()</span><br><span class="line">                .authenticated()</span><br><span class="line">                .and()</span><br><span class="line">            .formLogin()</span><br><span class="line">                .loginPage(&quot;/login&quot;)</span><br><span class="line">                .failureUrl(&quot;/login/error&quot;)</span><br><span class="line">                .permitAll()</span><br><span class="line">                .and()</span><br><span class="line">            .logout()</span><br><span class="line">                .permitAll();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Override</span><br><span class="line">    protected void configure(AuthenticationManagerBuilder auth) &#123;</span><br><span class="line">        auth.authenticationProvider(daoAuthenticationProvider());</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    @Bean</span><br><span class="line">    public PasswordEncoder passwordEncoder() &#123;</span><br><span class="line">        return new BCryptPasswordEncoder();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    private DaoAuthenticationProvider daoAuthenticationProvider() &#123;</span><br><span class="line">        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();</span><br><span class="line">        provider.setHideUserNotFoundExceptions(false);</span><br><span class="line">        provider.setPasswordEncoder(passwordEncoder());</span><br><span class="line">        provider.setUserDetailsService(customerUserDetailService);</span><br><span class="line">        return provider;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<ol start="6">
<li><p>登录错误方法修改如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">@RequestMapping(&quot;/login&quot;)</span><br><span class="line">@Controller</span><br><span class="line">public class LoginController &#123;</span><br><span class="line"></span><br><span class="line">    private static final String ERROR_PASSWORD_MESSAGE = &quot;Bad credentials&quot;;</span><br><span class="line"></span><br><span class="line">    @RequestMapping(&quot;/error&quot;)</span><br><span class="line">    public String error(HttpServletRequest request, Model model) &#123;</span><br><span class="line">        String errorMessage = &quot;&quot;;</span><br><span class="line">        Object exceptionObj = request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);</span><br><span class="line">        if (exceptionObj instanceof AuthenticationException) &#123;</span><br><span class="line">            errorMessage = ((AuthenticationException) exceptionObj).getMessage();</span><br><span class="line">            if (errorMessage.equalsIgnoreCase(ERROR_PASSWORD_MESSAGE)) &#123;</span><br><span class="line">                errorMessage = &quot;密码错误&quot;;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        model.addAttribute(&quot;errorMessage&quot;, errorMessage);</span><br><span class="line">        return &quot;login&quot;;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>登录页面修改如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html lang=&quot;zh&quot; xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;</span><br><span class="line">&lt;head&gt;</span><br><span class="line">    &lt;meta charset=&quot;UTF-8&quot;&gt;</span><br><span class="line">    &lt;title&gt;Login page&lt;/title&gt;</span><br><span class="line">&lt;/head&gt;</span><br><span class="line">&lt;body&gt;</span><br><span class="line">&lt;h1&gt;Login page&lt;/h1&gt;</span><br><span class="line">&lt;p th:text=&quot;$&#123;errorMessage&#125;&quot;&gt;&lt;/p&gt;</span><br><span class="line">&lt;form th:action=&quot;@&#123;/login&#125;&quot; method=&quot;post&quot;&gt;</span><br><span class="line">    &lt;label for=&quot;username&quot;&gt;Username&lt;/label&gt;:</span><br><span class="line">    &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; autofocus=&quot;autofocus&quot; /&gt; &lt;br /&gt;</span><br><span class="line">    &lt;label for=&quot;password&quot;&gt;Password&lt;/label&gt;:</span><br><span class="line">    &lt;input type=&quot;password&quot; id=&quot;password&quot; name=&quot;password&quot; /&gt; &lt;br /&gt;</span><br><span class="line">    &lt;input type=&quot;submit&quot; value=&quot;Login&quot; /&gt;</span><br><span class="line">&lt;/form&gt;</span><br><span class="line">&lt;/body&gt;</span><br><span class="line">&lt;/html&gt;</span><br></pre></td></tr></table></figure>
</li>
</ol>
<h1 id="信息国际化"><a href="#信息国际化" class="headerlink" title="信息国际化"></a>信息国际化</h1><p>前面对于密码有误的输出通过硬编码的方式实现的，其实Spring Security自带国际化配置文件<br><img src="https://mdsystem.oss-cn-hangzhou.aliyuncs.com/blog/%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_230da13e-57ed-4fb0-b64f-0be8c304a913.png" alt=""><br>如果我们想自定义，我们可以在项目的resource目录下面创建org/springframework/security/messages_zh_CN.properties来覆盖默认的<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">AbstractUserDetailsAuthenticationProvider.badCredentials=输入的密码有误</span><br></pre></td></tr></table></figure></p>
<p>这样我们再输入错误的密码，就可以看到我们配置的错误信息了</p>
<h1 id="github代码"><a href="#github代码" class="headerlink" title="github代码"></a>github代码</h1><p><a href="https://github.com/a601942905git/boot-example/tree/master/boot-example-security3" target="_blank" rel="noopener">Spring Boot Security进阶(二)</a></p>
<h1 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h1><p><a href="https://tomoya92.github.io/2018/05/21/spring-security-capatch-remember-me/" target="_blank" rel="noopener">spring-security 实现用户名密码/图片验证码验证和记住我以及登录次数判断功能</a></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Spring-Boot/" rel="tag"># Spring Boot</a>
          
            <a href="/tags/Spring-Security/" rel="tag"># Spring Security</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/12/18/Spring-Boot-Security进阶-一/Spring-Boot-Security进阶-一/" rel="next" title="Spring Boot Security进阶(一)">
                <i class="fa fa-chevron-left"></i> Spring Boot Security进阶(一)
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/12/20/Spring-Boot-Security分析/Spring-Boot-Security分析/" rel="prev" title="Spring Boot Security分析">
                Spring Boot Security分析 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Wolf、Heart</p>
              <p class="site-description motion-element" itemprop="description">主要用于分享平时学习的只是以及遇到的困难，帮助自己以及需要的人一起共同成长</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">45</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">14</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">13</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#Spring-Boot-Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化"><span class="nav-number">1.</span> <span class="nav-text">Spring Boot Security进阶，实现不同用户分配不用的角色，拥有不同的操作权限。并实现展示具体错误原因，以及信息展示国际化</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#登录返回具体的错误原因"><span class="nav-number"></span> <span class="nav-text">登录返回具体的错误原因</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#信息国际化"><span class="nav-number"></span> <span class="nav-text">信息国际化</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#github代码"><span class="nav-number"></span> <span class="nav-text">github代码</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#参考文献"><span class="nav-number"></span> <span class="nav-text">参考文献</span></a></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Wolf、Heart</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
